import BtnUI from '../core/base/BtnUI';
import { showAdminUI } from './AdminUi'
import { showMainLandUI } from './LandUi'

/**
* @param {import("@minecraft/server").Player} player
*/
export async function showMainGui(player) {
    const form = new BtnUI(player);

    form.__Title = "主菜单";

    form.add_btn("我的", "textures/ui/icon_steve", function () {
        showMineGui(player);
    })

    form.add_btn('主城', "textures/ui/permissions_op_crown_hover.png", function () {
        player.teleport({ x: 2000.5, y: 100, z: 2000.5 });
    })

    form.add_btn('地皮', "textures/ui/world_glyph_color_2x", function () {
        showMainLandUI(player);
    })

    form.add_btn('红石区', "textures/blocks/redstone_block.png", function () {
        player.teleport({ x: 8, y: 100, z: 8 });
    })

    form.add_btn('小游戏', "textures/ui/icon_multiplayer.png", function () {
        showGameUI(player);
    });

    if (player.hasTag('op')) {
        form.add_btn('管理员菜单', "textures/ui/permissions_op_crown_hover.png", function () {
            showAdminUI(player);
        });
    }

    form.show();
}

/**
* @param {import("@minecraft/server").Player} player
*/
async function showMineGui(player) {
    const form = new BtnUI(player);

    form.__Title = "我的";
    form.__Body = `你的名称为: ${player.name}\n你的UUID为: ${player.id}`;

    form.add_btn("返回", "textures/ui/import.png", function () {
        showMainGui(player);
    });

    form.show();
}

/**
* @param {import("@minecraft/server").Player} player
*/
async function showGameUI(player) {
    const form = new BtnUI(player);

    form.__Title = "小游戏";

    form.add_btn('PVP', "textures/ui/icon_recipe_equipment.png", function () {
        player.teleport({ x: 1000, y: 100, z: 1000 });
    });

    form.add_btn('跑酷', "textures/ui/xbox_dpad_up.png", function () {
        player.teleport({ x: 2560, y: 130, z: 2655 });
    });

    form.add_btn('滑冰', "textures/ui/small_fish_bevel.png", function () {
        player.teleport({ x: 0, y: 100, z: 0 });
    });

    form.add_btn('返回', "textures/ui/import.png", function () {
        showMainGui(player);
    });

    form.show();
}
